home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _842FE410638B481D8E2C52780EEDC2D2 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.7 KB  |  56 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.       VS20Only
  11.  
  12.       VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
  13.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS, ATTEN, LIGHT_MATRIX, uniform float4x4 TexMatrix }
  14.       DeclarationsScript
  15.       {
  16.         IN_T0_TANG
  17.         OUT_T0_T1_T2_T3_T4_T5_T6_T7_C0
  18.       }
  19.       PositionScript = PosCommon
  20.       CoreScript
  21.       {
  22.         OUT.Tex0.xy = IN.TexCoord0.xy;
  23.         OUT.Tex1.xy = IN.TexCoord0.xy;
  24.         OUT.Tex6.xy = IN.TexCoord0.xy;
  25.         OUT.Tex4 = mul(LightMatrix, vPos);
  26.  
  27.         TANG_MATR
  28.  
  29.         float3 lVec = LightPos.xyz - vPos.xyz;
  30.         float3 lightVec = mul(objToTangentSpace, lVec);          
  31.         float3 vDist = PROC_ATTENPIX;
  32.         
  33.         OUT.Tex5.xyz = vDist;
  34.         OUT.Color.xyz = vDist;
  35.         
  36.         OUT.Tex2.xyz = lightVec;
  37.  
  38.         // store normalized light vector
  39.         float3 vVec = CameraPos.xyz - vPos.xyz;
  40.         float3 viewVec = mul(objToTangentSpace, vVec);
  41.  
  42.         // compute half angle vector
  43.         float3 halfAngleVector = normalize(viewVec) + normalize(lightVec);
  44.  
  45.         // transform light vector from object space to tangent space and pass it as a tex coords
  46.         OUT.Tex3.xyz = halfAngleVector;
  47.  
  48.         float3 tCamVec = normalize(vVec);
  49.         float3 tNormal = IN.TNormal.xyz;
  50.         float3 tRef = dot(tNormal.xyz, tCamVec.xyz) * tNormal.xyz * 2 - tCamVec.xyz;
  51.         float4 tRM;
  52.         tRM.xyz = tRef.xyz;
  53.         tRM.w = vPos.w;
  54.         OUT.Tex7 = mul(tRM, TexMatrix);
  55.       }
  56.